<?php
class MediaAction extends PublicAction
{
    public function show()
    {
        if(empty($_GET['media']))
            return;

        $mediaDao = D("Media");
        $media = $mediaDao->where("mediahash=".$_GET["media"])->find();
        if($media){
            $filepath = C("MEDIA_DIR").$media["savedir"]."/".$media["date"]."_".$media["name"];
            import("ORG.Net.Http");
            Http::download($filepath,$media['name']);
        }
    }


    public function download()
    {

         if(empty($_GET['media']))
            return;


        $mediaDao = D("Media");
        $mediaDao->incDownload($_GET["media"]);
        $this->show();
    }

}
?>